.\" Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Automatically generated by Pandoc 2.3.1
.\"
.TH "JAOTC" "1" "2020" "JDK 16" "JDK Commands"
.hy
.SH NAME
.PP
jaotc \- The Java static compiler that produces native code for compiled
Java methods
.SH SYNOPSIS
.PP
\f[CB]jaotc\f[R] [\f[I]options\f[R]] [\f[I]name\f[R] | \f[I]list\f[R]]
.TP
.B \f[I]options\f[R]
Command\-line options separated by spaces.
See \f[B]jaotc Options\f[R].
.RS
.RE
.TP
.B \f[I]name\f[R]
The Java class or jar file from which Java methods will be compiled.
.RS
.RE
.TP
.B \f[I]list\f[R]
Colon (\f[CB]:\f[R]) separated list of class names, modules, jar files or
directories which contain class files.
.RS
.RE
.SH DESCRIPTION
.PP
The \f[CB]jaotc\f[R] command is a Java Ahead\-Of\-Time (AOT) static
compiler which produces native code in the form of a shared library for
the Java methods in specified Java class files.
The Java Virtual Machine can load these AOT libraries and use native
code from them when corresponding Java methods are called.
By using \f[CB]jaotc\f[R], there is no need to wait for the JIT compiler
to generate (by compiling bytecode) the fast native code for these Java
methods.
The code is already generated by \f[CB]jaotc\f[R] and ready to be
immediately used.
For the same reason, there is no need to execute these methods in the
Interpreter because fast compiled native code can be executed instead.
.PP
\f[B]Note:\f[R]
.PP
The \f[CB]jaotc\f[R] command is experimental.
See \f[B]JEP 295: Ahead\-of\-Time Compilation\f[R]
[https://openjdk.java.net/jeps/295] for complete details.
.SH JAOTC OPTIONS
.TP
.B \f[CB]\-\-output\f[R] \f[I]file\f[R]
Output file name.
Default name is "unnamed.so".
.RS
.RE
.TP
.B \f[CB]\-\-class\-name\f[R] \f[I]class\-names\f[R]
List of Java classes to compile.
.RS
.RE
.TP
.B \f[CB]\-\-jar\f[R] \f[I]jar\-files\f[R]
List of JAR files to compile.
.RS
.RE
.TP
.B \f[CB]\-\-module\f[R] \f[I]modules\f[R]
List of Java modules to compile.
.RS
.RE
.TP
.B \f[CB]\-\-directory\f[R] \f[I]dirs\f[R]
List of directories to search for files to compile.
.RS
.RE
.TP
.B \f[CB]\-\-search\-path\f[R] \f[I]dirs\f[R]
List of directories to search for specified files.
.RS
.RE
.TP
.B \f[CB]\-\-compile\-commands\f[R] \f[I]file\f[R]
Name of the file containing the compile commands:
.RS
.TP
.B \f[CB]exclude\f[R]
Excludes compilation of specified methods.
.RS
.RE
.TP
.B \f[CB]compileOnly\f[R]
Compiles only specified methods.
.RS
.RE
.PP
Regular expressions are used to specify classes and methods.
For example:
.IP
.nf
\f[CB]
exclude\ sun.util.resources..*.TimeZoneNames_.*.getContents\\(\\)\\[\\[Ljava/lang/Object;\ 
exclude\ sun.security.ssl.*\ 
compileOnly\ java.lang.String.*
\f[R]
.fi
.RE
.TP
.B \f[CB]\-\-compile\-for\-tiered\f[R]
Generates profiling code for tiered compilation.
By default, profiling code is not generated (could be changed in a
future).
.RS
.RE
.TP
.B \f[CB]\-\-compile\-with\-assertions\f[R]
Generates code with java assertions.
By default, assertions code is not generated.
.RS
.RE
.TP
.B \f[CB]\-\-compile\-threads\f[R] \f[I]number\f[R]
Sets the number of compilation threads used.
The default value is \f[CB]min(16,\ available_cpus)\f[R].
.RS
.RE
.TP
.B \f[CB]\-\-ignore\-errors\f[R]
Ignores all exceptions thrown during class loading.
By default, the tool will exit compilation if class loading throws an
exception.
.RS
.RE
.TP
.B \f[CB]\-\-exit\-on\-error\f[R]
Exits on compilation errors.
By default, failed compilation is skipped and compilation of other
methods continues.
.RS
.RE
.TP
.B \f[CB]\-\-info\f[R]
Prints information about compilation phases.
.RS
.RE
.TP
.B \f[CB]\-\-verbose\f[R]
Prints more details about compilation phases.
.RS
.RE
.TP
.B \f[CB]\-\-debug\f[R]
Prints comprehensive details.
.RS
.RE
.TP
.B \f[CB]\-\-help\f[R] or \f[CB]\-h\f[R] or \f[CB]\-?\f[R]
Prints a summary of standard options and exits the tool.
.RS
.RE
.TP
.B \f[CB]\-\-version\f[R]
Prints version information.
.RS
.RE
.TP
.B \f[CB]\-J\f[R]\f[I]flag\f[R]
Provides a flag to pass to the runtime system.
To pass more than one flag, provide an instance of this option for each
flag or flag argument needed.
.RS
.RE
.SH JAOTC EXAMPLES
.PP
Use the \f[CB]jaotc\f[R] tool to execute AOT compilation.
.IP
.nf
\f[CB]
jaotc\ \-\-output\ libHelloWorld.so\ HelloWorld.class
\f[R]
.fi
.PP
Specify a generated AOT library during application execution:
.IP
.nf
\f[CB]
java\ \-XX:+UnlockExperimentalVMOptions\ \-XX:AOTLibrary=./libHelloWorld.so\ HelloWorld
\f[R]
.fi
